<?php
use think\facade\Route;
use app\api\middleware\Auth;

/* 用户登录注册 */
Route::post('login$','Login/login');                         // 登录接口

Route::get('test$','Test/test');                         // 测试
Route::get('translate','Common/translate');                         // 翻译接口

Route::group('index',function () {
    Route::get('/complex','Index/complex');
    Route::get('/publicCategories','Index/publicCategories');
    Route::delete('/cache','Index/clearCache');
});

// 聚合商品
Route::group('/productMerge',function () {
    Route::get('/by-urlname','ProductMerge/getProductMergeId');
    Route::get('/:id','ProductMerge/getProductMergeDetail');
    Route::get('','ProductMerge/getProductMergeList');
});

// goaffpro
Route::group('/goaffpro',function () {
    Route::get('','GoAffPro/searchAffiliate');
    Route::post('','GoAffPro/createAffiliateOrder');
    Route::patch('','GoAffPro/updateAffiliateOrder');
});


Route::group('coinpal',function () {
    Route::post('notify$','CoinPal/notify');
    Route::post('redirect$','CoinPal/redirect');
    Route::get('redirect$','CoinPal/redirect');
    Route::get('cancel$','CoinPal/cancel');
    Route::get('success$','CoinPal/success');
});

Route::group('register',function () {
    Route::post('/$','Register/register');                             // 注册接口
    Route::get('getEmailCode$','Register/getEmailCode');              // 获取验证码
});

Route::group('common',function () {
    Route::get('getEmailCode','Common/getEmailCode');                             // 注册接口
});

Route::group('miners',function () {
    Route::post('profit','Miners/profit');                             // 矿机
});


Route::group('retrieve',function () {
    Route::post('verify$','Retrieve/verify');                    // 验证账号
    Route::put('password$','Retrieve/password');                 // 设置密码
    Route::get('getEmailCode$','Retrieve/getEmailCode');         // 获取验证码
});

/* 国家地区 */
Route::group('region',function () {
    Route::get('country$','Region/countryList');                     // 国家列表
    Route::get('area$','Region/area');                               // 城市
    Route::get('city$','Region/cityList');                           // 城市
    Route::get('prefix$','Region/prefixList');                           // 手机号前缀
});

/* 邮箱订阅 */
Route::group('subscribe',function () {
    Route::post('email$','Subscribe/email');                     // 国家列表
});


Route::group('miner',function () {
    Route::get('video/list$','MinerVideo/list');                          // 矿机视频列表
    Route::get('video/detail$','MinerVideo/detail');                     // 矿机视频详情
    Route::get('profit','ProductProfit/profit');                     // 获取指定矿机收益数据
    Route::get('select','ProductProfit/select');                     // 矿机收益下拉数据
    Route::get('historyIncome','ProductProfit/historyIncome');                     // 矿机历史收益
});

#文章
Route::group('articles',function () {
    Route::get('','index');              // 文章列表
    Route::get('detail$','detail');          // 文章详情
})->prefix('Article/');

#员工信息列表
Route::group('staff',function () {
    Route::get('list$','index');                     // 员工列表
    Route::post('auth','auth');                      // 员工验证
})->prefix('Staff/');

#站内信
Route::group('message',function () {
    Route::post('','save');                      // 站内信创建
})->prefix('Message/');


#合作伙伴
Route::group('partner',function () {
    Route::get('list$','index');                      // 合作伙伴
})->prefix('Partner/');

#矿池
Route::group('minerPool',function () {
    Route::get('list$','index');                      // 矿池
    Route::get('getListBySku','getListBySku');                      // 矿池
})->prefix('MinerPool/');

#手册
Route::group('manualBook',function () {
    Route::get('list$','index');
})->prefix('ManualBook/');

#广告
Route::group('advertisement',function () {
    Route::get('list$','index');                      // 广告列表
})->prefix('Advertisement/');



Route::group(function () {


    Route::group('manualBook',function () {
        Route::get('download$','download');
    })->prefix('ManualBook/');  // 矿机手册下载  需要登录态


    /* 用户用心 */
    Route::group('user',function () {
        Route::get('information$','Users/information');               // 用户信息
        Route::get('dashboard$','Users/dashboard');                       // 控制台
    });

    /* 商品 */
    Route::group('product',function () {
        Route::get('filter/group$','ProductFilter/group');               // 筛选器组
        Route::get('filter/brand$','ProductFilter/brand');               // 品牌
        Route::get('filter/coin$','ProductFilter/coin');                 // 货币算法
        Route::get('filter/warehouse$','ProductFilter/warehouse');       // 仓库
    });

    /* 供应商-商品 */
    Route::group('distributor',function () {
        Route::post('product$','DistributorProduct/list');                        // 供应商 - 商品列表
        Route::get('order$','DistributorOrder/list');                             // 供应商 - 订单列表
        Route::get('order/status/list$','DistributorOrder/getStatusList');       // 订单列表
        Route::get('order/detail$','DistributorOrder/orderDetail');               // 供应商 - 订单详情
        Route::get('assets$','DistributorOrder/assets');                          // 供应商 - 我的资产
        Route::post('checkout$','DistributorOrder/checkout');                     // 供应商 - 结算页面
        Route::post('create$','DistributorOrder/create');                         // 供应商 - 发货
        Route::post('order/payment/voucher$','DistributorOrder/paymentVoucher');  // 供应商 - 支付凭证
        Route::post('order/payment$','DistributorOrder/payment');                  // 供应商 - 拉起支付
        Route::delete('order/voucher/remove$','DistributorOrder/VoucherRemove');  // 供应商 - 删除支付凭证
    });

    /* 购物车 */
    Route::group('cart',function () {
        Route::get('/$','Carts/list');                                  // 购物车列表
        Route::post('add$','Carts/add');                                // 加入购物车
        Route::post('bulkAdd$','Carts/bulkAdd');                                // 加入购物车
        Route::put('update$','Carts/update');                           // 更新购物车
        Route::delete('remove$','Carts/remove');                        // 移除购物车
        Route::delete('clearAll$','Carts/clearAll');                    // 清空购物车
    });

    /* 用户中心 */
    Route::group('user',function () {
        Route::get('info$','Users/info');                           // 用户中心
        Route::put('/update/info$','Users/updateInfo');             // 更新基础信息
        Route::put('/update/phone$','Users/updatePhone');           // 更新手机号
        Route::put('/update/email$','Users/updateEmail');           // 更新邮箱
        Route::put('/update/password$','Users/updatePassword');     // 更新密码
    });

    /* 地址管理 */
    Route::group('address',function () {
        Route::get('/$','Address/list');                     // 地址列表
        Route::get('/list$','Address/getList');              // 地址列表
        Route::get('detail','Address/detail');               // 地址详情
        Route::post('add$','Address/save');                  // 添加地址
        Route::put('edit$','Address/save');                  // 修改地址
        Route::put('set/default$','Address/setDefault');     // 设置默认
        Route::delete('del$','Address/del');                 // 删除地址
    });

    /* 订单管理 */
    Route::group('order',function () {
        Route::get('/$','Order/list');                          // 订单列表
        Route::get('status/list$','Order/getStatusList');       // 订单状态
        Route::get('calculatePrice$','Order/calculatePrice');       // 计算价格
        Route::post('checkout','Order/checkout');               // 订单结算
        Route::post('create$','Order/create');                         //  统一下单接口
        Route::get('list$','Order/list');                              //  订单列表
        Route::get('detail$','Order/detail');                          //  订单详情
        Route::post('payment/voucher$','Order/PaymentVoucher');        //  上传凭证
        Route::delete('voucher/remove$','Order/VoucherRemove');              //  删除上传凭证
        Route::post('payment$','Order/payment');             //  拉起支付
        Route::put('cancel$','Order/cancel');             //  订单取消
        Route::put('set/address$','Order/setAddress');             //  订单取消
        Route::get('contractPreview/:id','Order/contractPreview');       // 合同预览
    });

    /* 获取物流信息 */
    Route::group('logistics',function () {
        Route::post('fee$','Logistics/fee');                   //  通过购物车获取运费
        Route::post('order$','Logistics/orderFee');                 //  通过订单获取运费
        Route::post('shippingMethod$','Logistics/shippingMethod');                 //  通过订单获取运费
    });

    /* 优惠券 */
    Route::group('discount',function () {
        Route::post('','Discount/checkCode');                   //  优惠券检查
        Route::get('my','Discount/myCoupon');                   //  我的优惠券

    });

    Route::post('logout','Login/logout');      // 退出系统

})->middleware([Auth::class]);



